<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>检查结果管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			//$("#name").focus();
			$("#inputForm").validate({
				submitHandler: function(form){
					loading('正在提交，请稍等...');
					form.submit();
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
		});
		function addRow(list, idx, tpl, row){
			$(list).append(Mustache.render(tpl, {
				idx: idx, delBtn: true, row: row
			}));
			$(list+idx).find("select").each(function(){
				$(this).val($(this).attr("data-value"));
			});
			$(list+idx).find("input[type='checkbox'], input[type='radio']").each(function(){
				var ss = $(this).attr("data-value").split(',');
				for (var i=0; i<ss.length; i++){
					if($(this).val() == ss[i]){
						$(this).attr("checked","checked");
					}
				}
			});
		}
		function delRow(obj, prefix){
			var id = $(prefix+"_id");
			var delFlag = $(prefix+"_delFlag");
			if (id.val() == ""){
				$(obj).parent().parent().remove();
			}else if(delFlag.val() == "0"){
				delFlag.val("1");
				$(obj).html("&divide;").attr("title", "撤销删除");
				$(obj).parent().parent().addClass("error");
			}else if(delFlag.val() == "1"){
				delFlag.val("0");
				$(obj).html("&times;").attr("title", "删除");
				$(obj).parent().parent().removeClass("error");
			}
		}
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li class="active"><a href="${ctx}/jcjg/drJg/form?id=${drJg.id}&rwId=${drJg.rwId}">${rwmc}&nbsp;&nbsp;&nbsp;检查结果<shiro:hasPermission name="vrw:vrw:view">${not empty drJg.id?'修改':'添加'}</shiro:hasPermission><shiro:lacksPermission name="vrw:vrw:view">查看</shiro:lacksPermission></a></li>
	</ul><br/>
	<form:form id="inputForm" modelAttribute="drJg" action="${ctx}/jcjg/drJg/save" method="post" class="form-horizontal">
		<form:hidden path="id"/>
        <form:hidden path="rwId"/>
		<sys:message content="${message}"/>		
		<div class="control-group">
			<label class="control-label">执法对象：</label>
			<div class="controls">
				${dxNames} 
			</div>
		</div>
        <div class="control-group">
                        <label class="control-label">检查执法记录：</label>
                        <div class="controls">
                            <table id="contentTable" class="table table-striped table-bordered table-condensed">
                                <thead>
                                    <tr>
                                        <th class="hide"></th>
                                        <th>执法对象</th>
                                        <th>问题记录</th>
                                        <th>是否合格</th>
                                        <th>处罚类型</th>
                                        <th>是否为失信依据</th>
                                        <shiro:hasPermission name="vrw:vrw:view"><th width="10">&nbsp;</th></shiro:hasPermission>
                                    </tr>
                                </thead>
                                <tbody id="drWtxxList">
                                </tbody>
                                <shiro:hasPermission name="vrw:vrw:view"><tfoot>
                                    <tr><td colspan="8"><a href="javascript:" onClick="addRow('#drWtxxList', drWtxxRowIdx, drWtxxTpl);drWtxxRowIdx = drWtxxRowIdx + 1;" class="btn">新增</a></td></tr>
                                </tfoot></shiro:hasPermission>
                            </table>
                            <script type="text/template" id="drWtxxTpl">//<!--
                                <tr id="drWtxxList{{idx}}">
                                    <td class="hide">
                                        <input id="drWtxxList{{idx}}_id" name="drWtxxList[{{idx}}].id" type="hidden" value="{{row.id}}"/>
                                        <input id="drWtxxList{{idx}}_delFlag" name="drWtxxList[{{idx}}].delFlag" type="hidden" value="0"/>
                                    </td>
                                    <td>
                                        <input id="drWtxxList{{idx}}_wtxxDxmc" name="drWtxxList[{{idx}}].wtxxDxmc" type="text" value="{{row.wtxxDxmc}}" maxlength="255" class="input-medium "/>
                                    </td>
                                    <td>
                                        <input id="drWtxxList{{idx}}_wtxxWtjl" name="drWtxxList[{{idx}}].wtxxWtjl" type="text" value="{{row.wtxxWtjl}}" maxlength="255" class="input-medium "/>
                                    </td>
                                    <td>
                                        <c:forEach items="${fns:getDictList('yes_no')}" var="dict" varStatus="dictStatus">
                                            <span><input id="drWtxxList{{idx}}_wtxxSfhg${dictStatus.index}" name="drWtxxList[{{idx}}].wtxxSfhg" type="radio" value="${dict.value}" data-value="{{row.wtxxSfhg}}"><label for="drWtxxList{{idx}}_wtxxSfhg${dictStatus.index}">${dict.label}</label></span>
                                        </c:forEach>
                                    </td>
                                    <td>
                                        <select id="drWtxxList{{idx}}_wtxxCflx" name="drWtxxList[{{idx}}].wtxxCflx" data-value="{{row.wtxxCflx}}" class="input-small ">
                                            <option value=""></option>
                                            <c:forEach items="${fns:getDictList('dr_cflx')}" var="dict">
                                                <option value="${dict.value}">${dict.label}</option>
                                            </c:forEach>
                                        </select>
                                    </td>
                                    <td>
                                        <c:forEach items="${fns:getDictList('yes_no')}" var="dict" varStatus="dictStatus">
                                            <span><input id="drWtxxList{{idx}}_wtxxSxyj${dictStatus.index}" name="drWtxxList[{{idx}}].wtxxSxyj" type="radio" value="${dict.value}" data-value="{{row.wtxxSxyj}}"><label for="drWtxxList{{idx}}_wtxxSxyj${dictStatus.index}">${dict.label}</label></span>
                                        </c:forEach>
                                    </td>
                                    <shiro:hasPermission name="vrw:vrw:view"><td class="text-center" width="10">
                                        {{#delBtn}}<span class="close" onclick="delRow(this, '#drWtxxList{{idx}}')" title="删除">&times;</span>{{/delBtn}}
                                    </td></shiro:hasPermission>
                                </tr>//-->
                            </script>
                            <script type="text/javascript">
                                var drWtxxRowIdx = 0, drWtxxTpl = $("#drWtxxTpl").html().replace(/(\/\/\<!\-\-)|(\/\/\-\->)/g,"");
                                $(document).ready(function() {
                                    var data = ${fns:toJson(drJg.drWtxxList)};
                                    for (var i=0; i<data.length; i++){
                                        addRow('#drWtxxList', drWtxxRowIdx, drWtxxTpl, data[i]);
                                        drWtxxRowIdx = drWtxxRowIdx + 1;
                                    }
                                });
                            </script>
                        </div>
                    </div>                
		<div class="control-group">
			<label class="control-label">问题数量：</label>
			<div class="controls">
				<form:input path="jgWtsl" htmlEscape="false" maxlength="11" class="input-xlarge  digits"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">问题对象数量：</label>
			<div class="controls">
				<form:input path="jgWtqysl" htmlEscape="false" maxlength="11" class="input-xlarge  digits"/>
			</div>
		</div>
<!--		<div class="control-group">
			<label class="control-label">计划ID：</label>
			<div class="controls">
				<form:input path="jhId" htmlEscape="false" maxlength="64" class="input-xlarge "/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">事项ID：</label>
			<div class="controls">
				<form:input path="sxId" htmlEscape="false" maxlength="64" class="input-xlarge "/>
			</div>
		</div>-->
		<div class="control-group">
			<label class="control-label">问题总结：</label>
			<div class="controls">
				<form:textarea path="remarks" htmlEscape="false" rows="4" maxlength="255" class="input-xxlarge "/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">上传附件：</label>
			<div class="controls">
				<form:hidden id="fj" path="fj" htmlEscape="false" maxlength="255" class="input-xlarge"/>
				<sys:ckfinder input="fj" type="files" uploadPath="/jcjg/drJg" selectMultiple="true"/>
			</div>
		</div>
		<div class="form-actions">
			<shiro:hasPermission name="vrw:vrw:view"><input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;</shiro:hasPermission>
			<input id="btnCancel" class="btn" type="button" value="返 回" onClick="history.go(-1)"/>
		</div>
	</form:form>
</body>
</html>